{n input
min+max output}


program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  i, n, max, min: integer;
  mass: array of integer;
  fin, fout: textFile;

begin
  assignFile (fin, 'input.txt');
  reset (fin);
  assignFile (fout, 'output.txt');
  rewrite (fout);

  readln (fin, n);
  setlength (mass, n);
  max:=mass[0];
  for i:= 0 to n-1 do
    read (fin, mass[i]);
  for i:= 0 to n-1 do
  begin
    if max<mass[i] then
    begin
      max:=mass[i];
    end;
  end;
  for i:= 0 to n-1 do
  begin
    if min>mass[i] then
    begin
      min:=mass[i];
    end;
  end;
  writeln (fout, max+min);

  closeFile (fin);
  closeFile (fout);
end.
 